package org.tech4j.edi.common.entity;

import jakarta.validation.constraints.NotNull;
import org.tech4j.edi.common.enums.RetryStatusEnum;

import java.util.Date;
import java.util.Map;
import java.util.Objects;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/7 10:48
 **/
public class RetryBizRecord {

    /**
     * 记录id
     */
    private String id;

    /**
     * 业务单据号
     */
    private String bizNo;

    /**
     * 业务id
     */
    private String bizId;

    /**
     * 业务类型
     */
    @NotNull(message = "业务类型不能为空")
    private String bizType;

    /**
     * 系统来源
     */
    private String bizSource;

    /**
     * 执行参数
     */
    private String bizParams;

    /**
     * 扩展信息
     */
    private String ext;

    /**
     * 备注
     */
    private String remark;

    /**
     * 记录状态
     */
    private RetryStatusEnum recordStatus;

    /**
     * 异常信息
     */
    private String errorMessage;

    /**
     * 上次执行时间
     */
    private Date lastOpTime;


    /**
     * 重试次数
     */
    private Integer retryTimes;

    /**
     * 版本号
     */
    private Integer version;

    /**
     * 分片key
     */
    private String shardingKey;

    /**
     * 扩展字段
     */
    private Map<String, String> extraField;

    /**
     * 环境变量
     */
    private String env;

    /**
     * 创建时间
     */
    private Date createdTime;

    /**
     * 修改时间
     */
    private Date modifiedTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBizNo() {
        return bizNo;
    }

    public void setBizNo(String bizNo) {
        this.bizNo = bizNo;
    }

    public String getBizId() {
        return bizId;
    }

    public void setBizId(String bizId) {
        this.bizId = bizId;
    }

    public String getBizType() {
        return bizType;
    }

    public void setBizType(String bizType) {
        this.bizType = bizType;
    }

    public String getBizSource() {
        return bizSource;
    }

    public void setBizSource(String bizSource) {
        this.bizSource = bizSource;
    }

    public String getBizParams() {
        return bizParams;
    }

    public void setBizParams(String bizParams) {
        this.bizParams = bizParams;
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public RetryStatusEnum getRecordStatus() {
        return recordStatus;
    }

    public void setRecordStatus(RetryStatusEnum recordStatus) {
        this.recordStatus = recordStatus;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Map<String, String> getExtraField() {
        return extraField;
    }

    public void setExtraField(Map<String, String> extraField) {
        this.extraField = extraField;
    }

    public Date getLastOpTime() {
        return lastOpTime;
    }

    public void setLastOpTime(Date lastOpTime) {
        this.lastOpTime = lastOpTime;
    }

    public Integer getRetryTimes() {
        return retryTimes;
    }

    public void setRetryTimes(Integer retryTimes) {
        this.retryTimes = retryTimes;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public String getShardingKey() {
        return shardingKey;
    }

    public void setShardingKey(String shardingKey) {
        this.shardingKey = shardingKey;
    }

    public String getEnv() {
        return env;
    }

    public void setEnv(String env) {
        this.env = env;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public Date getModifiedTime() {
        return modifiedTime;
    }

    public void setModifiedTime(Date modifiedTime) {
        this.modifiedTime = modifiedTime;
    }

    public Integer getAndAddRetryTimes() {
        return this.retryTimes++;
    }
}
